if exists (select 1
            from  sysobjects
           where  id = object_id('bd_enclosure')
            and   type = 'U')
   drop table bd_enclosure
go

/*==============================================================*/
/* Table: bd_enclosure                                          */
/*==============================================================*/
create table bd_enclosure (
   id                   int                  identity,
   order_id             numeric              not null,
   order_type           int                  not null,
   original_name        varchar(255)         null,
   enclosure_addr       varchar(255)         not null,
   creater_id           varchar(255)         null,
   create_time          datetime             not null default getdate(),
   constraint PK_BD_ENCLOSURE primary key (id)
)
go

if exists (select 1 from  sys.extended_properties
           where major_id = object_id('bd_enclosure') and minor_id = 0)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_enclosure'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '附件表',
   'user', @CurrentUser, 'table', 'bd_enclosure'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_enclosure')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'id')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_enclosure', 'column', 'id'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '表id',
   'user', @CurrentUser, 'table', 'bd_enclosure', 'column', 'id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_enclosure')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'order_id')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_enclosure', 'column', 'order_id'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '单子ID',
   'user', @CurrentUser, 'table', 'bd_enclosure', 'column', 'order_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_enclosure')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'order_type')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_enclosure', 'column', 'order_type'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '单子类型(1:请假,2:加班,3:补出勤)',
   'user', @CurrentUser, 'table', 'bd_enclosure', 'column', 'order_type'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_enclosure')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'original_name')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_enclosure', 'column', 'original_name'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '附件原始名称',
   'user', @CurrentUser, 'table', 'bd_enclosure', 'column', 'original_name'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_enclosure')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'enclosure_addr')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_enclosure', 'column', 'enclosure_addr'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '附件地址',
   'user', @CurrentUser, 'table', 'bd_enclosure', 'column', 'enclosure_addr'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_enclosure')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'creater_id')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_enclosure', 'column', 'creater_id'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '记录创建人',
   'user', @CurrentUser, 'table', 'bd_enclosure', 'column', 'creater_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_enclosure')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'create_time')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_enclosure', 'column', 'create_time'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '记录创建时间',
   'user', @CurrentUser, 'table', 'bd_enclosure', 'column', 'create_time'
go
